package com.xinlong.service.impl;

import com.xinlong.dao.IRolesdao;
import com.xinlong.entity.Permission;
import com.xinlong.entity.Role;
import com.xinlong.service.IroleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class IroleServiceimpl implements IroleService {

    @Autowired
    IRolesdao iRolesdao;

    public List<Role> findall() {
        return iRolesdao.findall();
    }

    public void save(Role role) {
        iRolesdao.save(role);
    }

    public List<Permission> findRoleByIdAndAllPermission(String id) {
        return iRolesdao.findRoleByIdAndAllPermission(id);
    }

    public Role findbyid(String id) {
        return iRolesdao.findbyid(id);
    }

    public void addRoleTopermissin(String roleid, String[] ids) {
        for(String id:ids){
            iRolesdao.addRoleTopermissin(roleid,id);
        }

    }

    public List<Permission> findRoleByIdAndAllPermission2() {
        return iRolesdao.findRoleByIdAndAllPermission2(null);
    }

    public void delRoleTopermissin(Integer id) {
        iRolesdao.delRoleTopermissin(id);
    }
}
